import fetch from "../../utils/fetch";
const globalData = getApp().globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scores:[]
  },
  size: 15,   //一次加载15条
  page:1,   //第几次加载
  count:0, //积分条数
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.size = 15;
    this.page = 1;
    this.count = 0;
    wx.showLoading({
      title: '积分数据加载中',
    })
    //获取积分记录
    this.getScores()
    .then(res=>{
      wx.hideLoading();
      this.setData({
        scores:res.data.scores,
      });
      this.count = res.data.count
    }).catch(err=>{
      this.onLoad();
    })
  },
  getScores(){
    return fetch('/score/list',{
      page:this.page,
      size:this.size,
      userId:globalData.userInfo.id
    })
  }  
})